/**
 * 清单梳理中材料的api js
 */
import request from "@/utils/request";

//主材料的 api  start
export function initMaterialsSysDictCode() {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      "/yxpz/materials/initMaterialsSysDictCode",
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    }
  });
}

/**
 * 根据主键id查询材料数据
 * @param {*} id
 */
export function getById(id) {
  return request({
    url: process.env.VUE_APP_KSTB_ROUTE_PATH + `/yxpz/materials/getById/${id}`,
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    }
  });
}

/**
 * 根据主键id删除材料
 * @param {*} id
 */
export function deleteById(id) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH + `/yxpz/materials/deleteById/${id}`,
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    }
  });
}

/**
 * 根据HDLOid查询清单主材料
 * @param {*} hdlOid
 */
export function queryMainByhdlOid(hdlOid) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      `/yxpz/materials/queryMainByhdlOid/${hdlOid}`,
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    }
  });
}
/**
 * 保存或更新材料数据
 * @param {*} data
 */
export function saveOrUpdate(data) {
  return request({
    url: process.env.VUE_APP_KSTB_ROUTE_PATH + "/yxpz/materials/saveOrUpdate",
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    },
    data: data
  });
}

//主材料的 api  end

//颗粒化材料的 api  start

/**
 * 根据父级主键查询下面的颗粒化材料数据
 * @param {*} parentOid
 */
export function queryGrainMaterialsByParentOid(parentOid) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      `/yxpz/materials/queryGrainMaterialsByParentOid/${parentOid}`,
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    }
  });
}

//颗粒化材料的 api  end

// 保存或者修改
export function updateByMaterialOid(data) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      "/yxpz/materials/updateByMaterialOid",
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    },
    data: data
  });
}

/**关联事项材料的api  start */

/**
 * 查询hdlOid下标准化模式的办事指南数据并且查询出关联的事项对应的材料数据集合
 * @param {*} hdlOid
 */
export function queryHandlePatternListAndServiceMaterials(hdlOid) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      `/yxpz/detailListBusinessGuide/queryHandlePatternListAndServiceMaterials/${hdlOid}`,
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    }
  });
}

/**
 * 保存通办清单和事项材料的关联关系
 * @param {*} data
 */
export function batchSaveOrUpdateMaterialsServiceRel(data) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      "/yxpz/materialsServiceRel/batchSaveOrUpdate",
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    },
    data: data
  });
}

/**
 * 根据materialOid查询已经关联材料的数据集合
 * @param {*} materialOid
 */
export function queryByMaterialOid(materialOid) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      `/yxpz/materialsServiceRel/queryByMaterialOid/${materialOid}`,
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    }
  });
}

/**关联事项材料的api  end  */
